From 2ff93fa03edebdae634aa76d6b1877e7c2b3a08e Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Thu, 14 Sep 2023 07:43:55 -0600 Subject: [PATCH] fix various "Redundancies in code" (#1178) * fix "Redundant elaborted type specifier" * fix "Redundant 'inline' specifier" * fix "redundant 'const' specifier on a constexpr variable" * remove "Redundant qualifier" * add /out/, /.vs/ to .gitignore, and sort. --- .gitignore | 62 +++++++++++++++++++++++--------------------- exif.h | 2 +- garmin.cc | 8 +++--- garmin_gpi.h | 10 +++---- garmin_txt.cc | 2 +- googletakeout.cc | 4 +-- igc.cc | 2 +- igc.h | 44 +++++++++++++++---------------- jeeps/gps.h | 8 +++--- jeeps/gpsapp.cc | 2 +- jeeps/gpscom.cc | 18 ++++++------- jeeps/gpscom.h | 16 ++++++------ jeeps/gpsprot.cc | 7 +++-- jeeps/gpsusbcommon.h | 2 +- mkshort.h | 2 +- mtk_logger.cc | 12 ++++----- skytraq.cc | 12 ++++----- v900.cc | 8 +++--- 18 files changed, 111 insertions(+), 110 deletions(-) diff --git a/.gitignore b/.gitignore index 8da97ca49..6d7d77f69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,21 @@ +*.a +*.o +*.swp +.ninja_deps +.ninja_log +.qmake.cache +.qmake.stash +.qt +/*.gcda +/*.gcno +/*.gcov +/.vs/ +/.vscode/ +/GPSBabel +/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2 +/GPSBabel[0-9]*.[0-9]*.[0-9]*/ +/Makefile +/autogen/ /autom4te.cache/ /babelweb/ /bld/ @@ -8,46 +26,30 @@ /config.status /cscope.out /debug/ +/empty +/gbversion.h /gpsbabel /gpsbabel-debug /gpsbabel.exe /gpsbabel.fo +/gpsbabel.gch/ /gpsbabel.html /gpsbabel.pdf +/gpsbabel.rc /gpsbabel_autogen/ /gpsbabel_coverage.xml -/Makefile -.qmake.cache -.qmake.stash -/GPSBabel -/*.gcda -/*.gcno -/*.gcov -*.o -*.a -.ninja_deps -.ninja_log -.qt -build.ninja -rules.ninja -cmake_install.cmake -CMakeCache.txt -CMakeFiles/ -CTestTestfile.cmake -/GPSBabel[0-9]*.[0-9]*.[0-9]*/ -/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2 +/makedoc /makelinuxdist.sh +/mkcapabilities /objects/ +/out/ +/qrc_gpsbabel.cpp /release/ -*.swp /tmp/ -/mkcapabilities -/gpsbabel.gch/ -/gpsbabel.rc -/autogen/ -/makedoc -/empty -/gbversion.h -/qrc_gpsbabel.cpp -/.vscode/ +CMakeCache.txt +CMakeFiles/ +CTestTestfile.cmake Testing +build.ninja +cmake_install.cmake +rules.ninja diff --git a/exif.h b/exif.h index 3c0a9f85e..2be58deda 100644 --- a/exif.h +++ b/exif.h @@ -115,7 +115,7 @@ private: // Return data value interpreted as EXIF_TYPE_LONG. // This is most useful when the type is EXIF_TYPE_LONG and the count is one, // which occurs for multiple specific tags where we need the value. - inline uint32_t toLong() const + uint32_t toLong() const { return data.at(0).value(); } diff --git a/garmin.cc b/garmin.cc index 159d3c02d..1382f9ead 100644 --- a/garmin.cc +++ b/garmin.cc @@ -484,7 +484,7 @@ waypt_read() } } -static int lap_read_nop_cb(int, struct GPS_SWay**) +static int lap_read_nop_cb(int, GPS_SWay**) { return 0; } @@ -864,7 +864,7 @@ waypoint_prepare() extern WaypointList* global_waypoint_list; int icon; - tx_waylist = (struct GPS_SWay**) xcalloc(n,sizeof(*tx_waylist)); + tx_waylist = (GPS_SWay**) xcalloc(n,sizeof(*tx_waylist)); for (i = 0; i < n; i++) { tx_waylist[i] = sane_GPS_Way_New(); @@ -1057,7 +1057,7 @@ route_write() { int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ - tx_routelist = (struct GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); + tx_routelist = (GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); cur_tx_routelist_entry = tx_routelist; for (int i = 0; i < n; i++) { @@ -1104,7 +1104,7 @@ track_prepare() { int32 n = track_waypt_count() + track_count(); - tx_tracklist = (struct GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); + tx_tracklist = (GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack)); cur_tx_tracklist_entry = tx_tracklist; for (int i = 0; i < n; i++) { tx_tracklist[i] = GPS_Track_New(); diff --git a/garmin_gpi.h b/garmin_gpi.h index 5594f6ffc..cdc972eb3 100644 --- a/garmin_gpi.h +++ b/garmin_gpi.h @@ -293,11 +293,11 @@ private: static bool compare_wpt_cb(const Waypoint* a, const Waypoint* b); static char compare_strings(const QString& s1, const QString& s2); static writer_data_t* wdata_alloc(); - static void wdata_free(GarminGPIFormat::writer_data_t* data); - static void wdata_add_wpt(GarminGPIFormat::writer_data_t* data, Waypoint* wpt); - void wdata_check(GarminGPIFormat::writer_data_t* data) const; - int wdata_compute_size(GarminGPIFormat::writer_data_t* data) const; - void wdata_write(const GarminGPIFormat::writer_data_t* data) const; + static void wdata_free(writer_data_t* data); + static void wdata_add_wpt(writer_data_t* data, Waypoint* wpt); + void wdata_check(writer_data_t* data) const; + int wdata_compute_size(writer_data_t* data) const; + void wdata_write(const writer_data_t* data) const; void write_category(const char* unused, const unsigned char* image, int image_sz) const; void write_header() const; void enum_waypt_cb(const Waypoint* ref) const; diff --git a/garmin_txt.cc b/garmin_txt.cc index 5fd72a870..8720621a1 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -124,7 +124,7 @@ static constexpr double kGarminUnknownAlt = 1.0e25; static constexpr char kDefaultDateFormat[] = "dd/mm/yyyy"; static constexpr char kDefaultTimeFormat[] = "HH:mm:ss"; -static inline bool is_valid_alt(double alt) +static bool is_valid_alt(double alt) { return (alt != unknown_alt) && (alt < kGarminUnknownAlt); } diff --git a/googletakeout.cc b/googletakeout.cc index d4b82f882..af824ae23 100644 --- a/googletakeout.cc +++ b/googletakeout.cc @@ -48,11 +48,11 @@ static const QList takeout_month_names{ "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" }; -static inline void takeout_fatal(const QString& message) { +static void takeout_fatal(const QString& message) { fatal(FatalMsg() << MYNAME << ": " << message); } -static inline void takeout_warning(const QString& message) { +static void takeout_warning(const QString& message) { Warning() << MYNAME << ": " << message; } diff --git a/igc.cc b/igc.cc index c26814354..ba643762b 100644 --- a/igc.cc +++ b/igc.cc @@ -467,7 +467,7 @@ void IgcFormat::read() int len = end - begin + 1; QString name = extension_definition.mid(4,3); igc_ext_type_t ext = get_ext_type(ext_type); - if (ext != IgcFormat::igc_ext_type_t::ext_rec_unknown) { + if (ext != igc_ext_type_t::ext_rec_unknown) { int factor = get_ext_factor(ext); ext_types_list.append(std::make_tuple(name, ext, begin, len, factor)); supported_extensions.append(name); diff --git a/igc.h b/igc.h index d0672811e..17c6bdaa1 100644 --- a/igc.h +++ b/igc.h @@ -131,17 +131,17 @@ private: rec_bad = 1, // Bad record }; - const QHash igc_extension_map{ - {"ENL", IgcFormat::igc_ext_type_t::ext_rec_enl}, - {"TAS", IgcFormat::igc_ext_type_t::ext_rec_tas}, - {"VAT", IgcFormat::igc_ext_type_t::ext_rec_vat}, - {"OAT", IgcFormat::igc_ext_type_t::ext_rec_oat}, - {"TRT", IgcFormat::igc_ext_type_t::ext_rec_trt}, - {"GSP", IgcFormat::igc_ext_type_t::ext_rec_gsp}, - {"FXA", IgcFormat::igc_ext_type_t::ext_rec_fxa}, - {"SIU", IgcFormat::igc_ext_type_t::ext_rec_siu}, - {"ACZ", IgcFormat::igc_ext_type_t::ext_rec_acz}, - {"GFO", IgcFormat::igc_ext_type_t::ext_rec_gfo}, + const QHash igc_extension_map{ + {"ENL", igc_ext_type_t::ext_rec_enl}, + {"TAS", igc_ext_type_t::ext_rec_tas}, + {"VAT", igc_ext_type_t::ext_rec_vat}, + {"OAT", igc_ext_type_t::ext_rec_oat}, + {"TRT", igc_ext_type_t::ext_rec_trt}, + {"GSP", igc_ext_type_t::ext_rec_gsp}, + {"FXA", igc_ext_type_t::ext_rec_fxa}, + {"SIU", igc_ext_type_t::ext_rec_siu}, + {"ACZ", igc_ext_type_t::ext_rec_acz}, + {"GFO", igc_ext_type_t::ext_rec_gfo}, }; // Will return zero if no match @@ -161,38 +161,38 @@ private: * A factor can never be zero, so this looks good to me. * Be careful. */ - int get_ext_factor(IgcFormat::igc_ext_type_t type) const + int get_ext_factor(igc_ext_type_t type) const { int ret = 0; switch (type) { - case IgcFormat::igc_ext_type_t::ext_rec_enl: + case igc_ext_type_t::ext_rec_enl: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_tas: + case igc_ext_type_t::ext_rec_tas: ret = 100; break; - case IgcFormat::igc_ext_type_t::ext_rec_vat: + case igc_ext_type_t::ext_rec_vat: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_oat: + case igc_ext_type_t::ext_rec_oat: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_trt: + case igc_ext_type_t::ext_rec_trt: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_gsp: + case igc_ext_type_t::ext_rec_gsp: ret = 100; break; - case IgcFormat::igc_ext_type_t::ext_rec_fxa: + case igc_ext_type_t::ext_rec_fxa: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_siu: + case igc_ext_type_t::ext_rec_siu: ret = 1; break; - case IgcFormat::igc_ext_type_t::ext_rec_acz: + case igc_ext_type_t::ext_rec_acz: ret = 10; break; - case IgcFormat::igc_ext_type_t::ext_rec_gfo: + case igc_ext_type_t::ext_rec_gfo: ret = 1; break; default: diff --git a/jeeps/gps.h b/jeeps/gps.h index 1efc420d9..951d8263a 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -247,7 +247,7 @@ typedef struct GPS_SCourse_Limits { } GPS_OCourse_Limits, *GPS_PCourse_Limits; -typedef int (*pcb_fn)(int, struct GPS_SWay**); +typedef int (*pcb_fn)(int, GPS_SWay**); #include "jeeps/gpsdevice.h" #include "jeeps/gpssend.h" @@ -270,9 +270,9 @@ extern char gps_save_string[GPS_ARB_LEN]; extern int gps_is_usb; extern int gps_baud_rate; -extern struct COMMANDDATA COMMAND_ID[2]; -extern struct LINKDATA LINK_ID[3]; -extern struct GPS_MODEL_PROTOCOL GPS_MP[]; +extern COMMANDDATA COMMAND_ID[2]; +extern LINKDATA LINK_ID[3]; +extern GPS_MODEL_PROTOCOL GPS_MP[]; extern const char* gps_marine_sym[]; extern const char* gps_land_sym[]; diff --git a/jeeps/gpsapp.cc b/jeeps/gpsapp.cc index 0eb115939..914b7e1c6 100644 --- a/jeeps/gpsapp.cc +++ b/jeeps/gpsapp.cc @@ -7571,7 +7571,7 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n) trkpt->distance_populated = 0; trkpt->heartrate = 0; trkpt->cadence = 0xff; - *trk = (struct GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); + *trk = (GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack)); memmove(&(*trk)[i+1], &(*trk)[i], (*n-i) * sizeof(GPS_PTrack)); (*trk)[i] = trkpt; i++; diff --git a/jeeps/gpscom.cc b/jeeps/gpscom.cc index f15c8f514..6408edf38 100644 --- a/jeeps/gpscom.cc +++ b/jeeps/gpscom.cc @@ -126,7 +126,7 @@ int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb) ** @return [int32] success ************************************************************************/ -int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(struct GPS_SWay**)) +int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**)) { int32 ret=0; @@ -1189,7 +1189,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 } /* Create & append course */ - crs = (struct GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); + crs = (GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse)); crs[n_crs] = GPS_Course_New(); if (!crs[n_crs]) { if (clp) xfree(clp); @@ -1203,7 +1203,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 crs[n_crs]->track_index = Unique_Track_Index(crs, n_crs); /* Create & append new lap */ - clp = (struct GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); + clp = (GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap)); clp[n_clp] = GPS_Course_Lap_New(); if (!clp[n_clp]) { if (clp) xfree(clp); @@ -1218,7 +1218,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 } /* Append new track points */ - ctk = (struct GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); + ctk = (GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack)); first_new_ctk = n_ctk; for (i=0; iishdr && (i>=n_trk || trk[i+1]->ishdr)) { @@ -1245,7 +1245,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 /* Convert waypoints to course points by searching closest track point & * append */ - cpt = (struct GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); + cpt = (GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point)); for (i=0; i replacements; /* Member Functions */ diff --git a/mtk_logger.cc b/mtk_logger.cc index c67605a79..1838a018d 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -202,7 +202,7 @@ struct data_item { short rcr; unsigned short timestamp_ms; double distance; - struct sat_info sat_data[32]; + sat_info sat_data[32]; }; struct mtk_loginfo { @@ -235,9 +235,9 @@ static char* OPT_erase_only; /* erase_only ? command option */ static char* OPT_log_enable; /* enable ? command option */ static char* csv_file; /* csv ? command option */ static char* OPT_block_size_kb; /* block_size_kb ? command option */ -static enum MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; +static MTK_DEVICE_TYPE mtk_device = MTK_LOGGER; -static struct mtk_loginfo mtk_info; +static mtk_loginfo mtk_info; const char LIVE_CHAR[4] = {'-', '\\','|','/'}; @@ -796,7 +796,7 @@ mtk_retry: static route_head* trk_head = nullptr; -static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) +static int add_trackpoint(int idx, unsigned long bmask, data_item* itm) { auto* trk = new Waypoint; @@ -978,7 +978,7 @@ static void mtk_csv_deinit() } /* Output a single data line in MTK application compatible format - i.e ignore any locale settings... */ -static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, struct data_item* itm) +static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, data_item* itm) { const char* fix_str = ""; if (bmask & (1U< 5) { diff --git a/skytraq.cc b/skytraq.cc index fe4ebb63a..eca79199c 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -581,7 +581,7 @@ SkytraqBase::ECEF_to_LLA(double x, double y, long z, double* lat, double* lon, d } void -SkytraqBase::state_init(struct read_state* pst) +SkytraqBase::state_init(read_state* pst) { auto* track = new route_head; track->rte_name = "SkyTraq tracklog"; @@ -600,7 +600,7 @@ SkytraqBase::state_init(struct read_state* pst) } Waypoint* -SkytraqBase::make_trackpoint(struct read_state* st, double lat, double lon, double alt) const +SkytraqBase::make_trackpoint(read_state* st, double lat, double lon, double alt) const { auto* wpt = new Waypoint; @@ -623,7 +623,7 @@ SkytraqBase::make_trackpoint(struct read_state* st, double lat, double lon, doub #define ITEM_SPEED(item) (item->type_and_speed[1] | ((item->type_and_speed[0] & 0x0F) << 8)) int -SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem, int len) const +SkytraqBase::process_data_item(read_state* pst, const item_frame* pitem, int len) const { int res = 0; double lat; @@ -766,7 +766,7 @@ SkytraqBase::process_data_item(struct read_state* pst, const item_frame* pitem, } int /* returns number of bytes processed (terminates on 0xFF i.e. empty or padding bytes) */ -SkytraqBase::process_data_sector(struct read_state* pst, const uint8_t* buf, int len) const +SkytraqBase::process_data_sector(read_state* pst, const uint8_t* buf, int len) const { int plen, ilen; @@ -924,7 +924,7 @@ SkytraqBase::skytraq_read_multiple_sectors(int first_sector, unsigned int sector void SkytraqBase::skytraq_read_tracks() const { - struct read_state st; + read_state st; uint32_t log_wr_ptr; uint16_t sectors_free, sectors_total, /*sectors_used_a, sectors_used_b,*/ sectors_used; int t, rc, got_sectors, total_sectors_read = 0; @@ -1240,7 +1240,7 @@ SkytraqfileFormat::rd_deinit() void SkytraqfileFormat::read() { - struct read_state st; + read_state st; int got_bytes; int opt_first_sector_val = xstrtoi(opt_first_sector, nullptr, 10); int opt_last_sector_val = xstrtoi(opt_last_sector, nullptr, 10); diff --git a/v900.cc b/v900.cc index e11129041..632195221 100644 --- a/v900.cc +++ b/v900.cc @@ -109,7 +109,7 @@ struct one_line_common_start { 1717**,T,090204,062634,31.765528N,035.207730E,772**,0***,0**,2D,SPS ,2.1**,1.9**,1.0**,********* */ struct one_line_advanced_mode { - struct one_line_common_start common; + one_line_common_start common; char fixmode[2]; /* "2D" or "3D" */ char comma10; /* ',' */ char valid[4]; /* "SPS " or "DGPS" */ @@ -130,7 +130,7 @@ struct one_line_advanced_mode { 1*****,T,090404,063401,31.765931N,035.206969E,821**,0***,0**,********* */ struct one_line_basic_mode { - struct one_line_common_start common; + one_line_common_start common; char vox[9]; /* voicetag recorded */ char cr; /* '\r' */ char lf; /* '\n' */ @@ -203,8 +203,8 @@ v900_read() { /* use line buffer large enough to hold either basic or advanced mode lines. */ union { - struct one_line_basic_mode bas; - struct one_line_advanced_mode adv; + one_line_basic_mode bas; + one_line_advanced_mode adv; char text[200]; /* used to read the header line, which is normal text */ } line; int lc = 0; -- 2.30.2